<template>
	<view class="search">
		<goodList :list="carList" v-if="carList.length"></goodList>
		<empty text="这里没有找到你要的车型~" v-else></empty>
		<u-loadmore :status="loadingText.status" :loading-text="loadingText.inLoading"
			:loadmore-text="loadingText.beforeLoading" :nomore-text="loadingText.nomoreText" :height="40"
			v-show='carList.length>=params.limit' />
	</view>
</template>

<script>
	import {
		get_car
	} from '@/api/contents/buyCar/buyCar.js'
	import goodList from '../../components/common/goodList/goodList.vue'
	import empty from '@/components/home/empty/empty.vue'
	export default {
		components: {
			goodList,
			empty
		},
		data() {
			return {
				carList: [],
				// car_params
				params: {
					limit: 10,
					page: 1,
					name:"",
				},
				loadingText: {
					inLoading: '努力加载中',
					beforeLoading: '上拉加载更多',
					nomoreText: '没有更多了',
					status: 'loadmore'
				}
			};
		},
		methods: {
			getCarList() {
				get_car(this.params).then(res => {
					if (res.code == 0) {
						if (res.data.list.length) {
							this.carList = [...this.carList, ...res.data.list]
							this.loadingText.status = 'loadmore';
						} else {
							this.loadingText.status = 'nomore'
						}
					}
				})

			},
		},
		onLoad(options) {
			this.params.name = options.name;
			this.getCarList();

		},
		onReachBottom() {
			this.loadingText.status = 'loading';
			this.params.page++;
			this.getCarList();
		},
	}
</script>

<style lang="scss" scoped>
	.search {
		background: #F5F7FA;

		.emptys {
			width: 80%;
			height: 500upx;
		}
	}
</style>
